package com.zbkj.service.event;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.core.ResolvableType;
import org.springframework.core.ResolvableTypeProvider;

@Data
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class EventMessage<T> implements ResolvableTypeProvider {

    private EventTypeEnum type;

    private T message;

    public static <T> EventMessage<T> build(EventTypeEnum type, T message) {
        return new EventMessage<>(type, message);
    }

    @Override
    public ResolvableType getResolvableType() {
        return ResolvableType.forClassWithGenerics(getClass(), ResolvableType.forInstance(message));
    }
}
